import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

//
export const useFirstCatalogData = defineStore('firstCatalogData', () => {
  const firstCatalogList = ref<any[]>([])
  const firstCatalogTable = ref<any>({})
  const firstCatalogTableAttribute=ref<any>({})
  const firstCatalogId = ref<number>(-1);
  const firstCatalogTableValueList = ref<any[]>([])
  const utilList = ref<any[]>([]);
  const utilTitle = ref<string>('');

  const setFirstCatalogList = (list: any[]) => {//设置一级目录list
    firstCatalogList.value = list;
  }
  const setFirstCatalogTable = (table: any)  => {//设置一级目录table
    firstCatalogTable.value = table.map((item:any) => {
      if (item.title === '版本图标') {
        item.width = 130
      }
      if (item.title === '下载') {
        item.width = 152
      }
      return item
    });
  }
  const setFirstCatalogTableAttribute = (attribute:any) => {
    firstCatalogTableAttribute.value = attribute;
  }

  const setFirstCatalogId = (id: number)  => {//设置一级目录id
    firstCatalogId.value = id;
  }

  const setFirstCatalogTableValueList = (list: any[])  => {//设置一级目录tabel的valueList
    console.log(list,'----firstCatalogTableValueList---')
    firstCatalogTableValueList.value = list;
  }

  const setUtilList = (list: any[]) => {
    utilList.value = list; 
  }

  const setUtilTitle = (_title:string) => {
    utilTitle.value = _title;
  }

  return {
    firstCatalogList,
    firstCatalogTable,
    firstCatalogTableAttribute,
    firstCatalogId, 
    firstCatalogTableValueList,
    utilList,
    utilTitle,
    setFirstCatalogList,
    setFirstCatalogTable,
    setFirstCatalogTableAttribute,
    setFirstCatalogId,
    setFirstCatalogTableValueList,
    setUtilList,
    setUtilTitle
  }
})
